<?php 
## include required files
/*******************************/
require_once '../../includefiles.php';
include_once("../../model/users.php");
include_once("../../model/trade.php");
include_once("../../model/leads.php");
include_once("../../model/state.php");
include_once("../../model/budget.php");
require_once '../../model/membershipplan.php';
require_once '../../redirect.php';

checkUserLogin();

if($_SESSION['user_type'] == '3')
{
	@header("location:".SITE_URL."/");
	exit;
}

$userObj = new Model_Users();
$tradeObj = new Model_TRADE();
$leadObj = new Model_Leads();
$objState = new Model_State();
$budgetObj = new Model_Budget();
$objPlan = new Model_PLAN();

$userId = $_SESSION['getbids_id'];

$userDetArray = $userObj->getUserDetailsByUserId($userId);

$smarty->assign('userDetArray',$userDetArray);

if($_GET['id1']!='')
{
	$postjobid = base64_decode($_GET['id1']);	
	//echo"<pre>";	print_R($postjobid);die();
	$jobdetArray = $userObj->getJobDetailsById($postjobid);
	if($jobdetArray['user_id']!='')
	{
		$getuserDet = $userObj->getUserDetailsByUserId($jobdetArray['user_id']);
		$jobdetArray['username'] = $getuserDet['first_name']." ".$getuserDet['last_name'];
	}
	if($jobdetArray['approx_budget']!='')
	{
		$getbudgetdetail = $budgetObj->getBudgetDetailsById($jobdetArray['approx_budget']);
		$jobdetArray['budgetname'] = $getbudgetdetail['budget_name'];
	}
	if($jobdetArray['trade_id']!='')
	{
		$gettradedetail = $tradeObj->getTradeCategoryDetailsById($jobdetArray['trade_id']);
		$jobdetArray['tradename'] = $gettradedetail['trade_category'];
	}
	if($jobdetArray['jobtype_id']!='')
	{
		$getjobtypedetail = $tradeObj->getTradeCategoryDetailsById($jobdetArray['jobtype_id']);
		$jobdetArray['jobtypename'] = $getjobtypedetail['trade_category'];
	}
			
	$smarty->assign('jobdetArray',$jobdetArray);
	
	$getuserjobviewArr = $userObj->getUserViewjobDetailsByUserIdJobId($userId,$postjobid);
	$smarty->assign('getuserjobviewArr',$getuserjobviewArr);
	
	//code for lead price
	if($jobdetArray['area']!='' && $jobdetArray['jobtype_id']!='' && $jobdetArray['approx_budget']!='')
	{
		$getleadprice =	$leadObj->getLeadPriceByAreaJobTypeBudget($jobdetArray['area'],$jobdetArray['jobtype_id'],$jobdetArray['approx_budget']);
		if($getleadprice['price']=='')
			$getleadprice['price'] = 10;
	}
	else
	{
			$getleadprice['price'] = 10;	
	}
	
	$smarty->assign('getleadprice',$getleadprice);

	
	
}
$getplandetail = $objPlan->getAllPlanInstedOfFree();
$smarty->assign("getplandetail", $getplandetail);


if($_SESSION['msg'] != ''){
	$smarty->assign("msg", $_SESSION['msg']);	
	unset($_SESSION['msg']);
}

$active ="leads";
$smarty->assign("active", $active);	



$smarty->display(TEMPLATEDIR.'/modules/leads/buylead.tpl');
unset($smarty);
?>
